﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NPOI.SS.UserModel.Charts;
using Simple.Repository.Models.Article;

namespace Simple.Repository.Models.Market
{
    /// <summary>
    /// 商品
    /// </summary>
    public class Commodity : BusinessFullEntityBase<Guid>
    {
        /// <summary>
        /// 商品名称/标题
        /// </summary>
        public string Title { get; set; } = "";

        /// <summary>
        /// 是否上架显示
        /// </summary>
        public bool IsShow { get; set; } = false;

        /// <summary>
        /// 库存
        /// </summary>
        public int StockCount { get; set; }

        /// <summary>
        /// 现已卖出多少
        /// </summary>
        public int SoldCount { get; set; }

        /// <summary>
        /// 价值积分
        /// </summary>
        public int Integral { get; set; }

        /// <summary>
        /// 内容或描述
        /// </summary>
        public string Content { get; set; } = "";

        /// <summary>
        /// 分类Id
        /// </summary>
        public Guid? CategoryId { get; set; }

        /// <summary>
        /// 分类信息
        /// </summary>
        public CommodityCategory? CategoryInfo = null;

        /// <summary>
        /// 图片集合
        /// </summary>
        public List<CommodityImage>? Images = null;

        public override void ConfigureEntity(ModelBuilder builder)
        {
            builder.Entity<Commodity>(entity =>
            {
                entity.ToTable("Commodity");
                entity.HasOne(c => c.CategoryInfo).WithMany(c => c.Commoditys).HasForeignKey(c => c.CategoryId);
            });
        }
    }
}
